﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DamageNum : MonoBehaviour
{

    public float lifeTime = 0.4f;     // 对象存活时间
    public float upSpeed = 2f;      // 文字上升速度

    private Text damageText;

    void Start()
    {
        Destroy(gameObject, lifeTime);
    }

    void Update()
    {
        transform.position += new Vector3(0, upSpeed * Time.deltaTime, 0);
    }


    public void ShowDamage(float damage)
    {
        damageText = GetComponent<Text>();
        damageText.text = damage.ToString();
    }
}
